function getReq(arr)
{
    var data;
    if(arr['request'] == undefined || arr['type'] == undefined)
    {
        return false;
    }
    else
    {
        $.ajax({
            url: '/admin/ajax.php'+arr['request'],
            dataType: 'json',
            data: data,
            success: function(result){
                var f = result;
            },
            error: function(data){
                alert(data);
            },
            ajaxSend: function(){
                      
            }
        });
        return f;
    }
}

function send(request, type)
{
    
    $.ajax({
        url: '/admin/ajax.php',
        dataType: 'json',
        success: function(data){
            sendJS(data,type);
        },
        error: function(data){
            alert(data);
        },
        ajaxSend: function(){
                      
        }
    });
        
}

function sendSimple(to){
    $.ajax({
            url: '/admin/ajax.php'+to,
            dataType: 'json',
            success: function(result){
                if(result.error==0){
                    $('#my-modal').modal('hide');
                }else{
                    $('#error').html(return_error(result.error_message))
                }
            },
            error: function(data){
                alert(data);
            },
            ajaxSend: function(){
                      
            }
        });
        
}

function modalFromFile(url){
    $('#my-modal').load(url);
    $('#my-modal').modal();
    //$('#modal-backdrop').show();
    //$('#my-modal').modal();
}

function modal(to,request,type)
{
    $.ajax({
        url: '/admin/ajax.php',
        dataType: 'json',
        success: function(result){
            //if(result.error == 0){
            $(to).html('result.data');
            $(to).modal({
                keyboard: true
            });
        //}else{
        //     console.log(result.error_message);
        //}
        },
        error: function(data){
            alert(data);
        },
        ajaxSend: function(){
                      
        }
    });
    
}

function sendJS(data,type)
{
    
}

function return_error(text){
    return '<div class="alert-message block-message error fade in" data-alert="alert">'+
           +' <a class="close" href="#">×</a>'+
            +'<p>'+text+'</p>'+
          +'</div>';
}